/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gradiente;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;
import javax.swing.JPanel;

/**
 *
 * @author uhgy3k
 */
public class Gradiente extends JPanel {
    int h,w,t;
    float matriz[][];
    Gradiente(int n, int m,int l) {
        h = n;
        w = m;
        t = l;
        Random ran = new Random();
        matriz = new float[n][m];
        for(int x = 0; x < n; x++)
            for(int y = 0; y < m; y++)
                matriz[x][y] = ran.nextFloat();
    }
    
    @Override
    public void paintComponent( Graphics g)
    {
        super.paintComponent(g);        
        for(int x = 0; x < h; x++)
            for(int y = 0; y < w; y++) {
                g.setColor(new Color(1,0,0,matriz[x][y]));
                g.fillRect(y*t, x*t, t, t);
            }
    }
    
}
